import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    uni()
  ],
  // 优化依赖配置
  optimizeDeps: {
    include: ['@/api/weapp.socket.io.js'],
    // 添加esbuild选项
    esbuildOptions: {
      target: 'es2015'
    }
  },
  build: {
    commonjsOptions: {
      include: [/weapp\.socket\.io\.js/, /node_modules/],
      transformMixedEsModules: true
    }
  },
  resolve: {
    alias: {
      '@': '/src'
    },
    extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
  }
});